<template>
	<div>
		<el-dialog title="内容预览" :visible.sync="visible" width="50%">
			<!-- 任务发起 -->
			<div v-if="msgCode === 'SMS_461815130'">
				<p>尊敬的{{ doctor.doctorName }}老师，您好：</p>
				<p>您本月的专家顾问协作任务已发起，可通过逸创胜美医生端进行开展并完成，如有疑问请联系客服微信或致电平台客服电话：400-889-6116（逸创胜美平台）</p>
			</div>
			<!-- 任务发起 -->
			<div v-if="msgCode === 'SMS_461860560'">
				<p>尊敬的{{ doctor.doctorName }}老师，您好：</p>
				<p>您本月的医患平台协作任务已发起，可通过逸创胜美医生端进行开展并完成，详见《逸创医患平台协作方案》，如有疑问请联系客服微信或致电平台客服电话：400-889-6116（逸创胜美平台）</p>
			</div>
			<!-- 积分变更 -->
			<div v-if="msgCode === 'SMS_461885162'">
				<p>尊敬的{{ doctor.doctorName }}老师，您好：</p>
				<p>当前账户积分&nbsp;<el-input v-model="params.point" size="mini"/>&nbsp;分，已完成协作明细可在医生端后台，我的积分中进行查询。如有疑问请联系客服微信或致电平台客服电话：400-889-6116（逸创胜美平台）</p>
			</div>
			<!-- 任务完成 -->
			<div v-if="msgCode === 'SMS_461830148'">
				<p>尊敬的{{ doctor.doctorName }}老师，您好：</p>
				<p>截止至&nbsp;<el-input v-model="params.deadline" size="mini" style="width: 130px;"/>，您的账户总积分&nbsp;<el-input v-model="params.point" size="mini"/>&nbsp;分，任务协作已达成，今日已兑换积分&nbsp;<el-input v-model="params.usedPoint" size="mini"/>&nbsp;分，剩余积分将自动累计。如有疑问请联系客服微信或致电平台客服电话：400-889-6116（逸创胜美平台）</p>
			</div>
			<!-- 任务未完成 -->
			<div v-if="msgCode === 'SMS_461890147'">
				<p>尊敬的{{ doctor.doctorName }}老师，您好：</p>
				<p>截止至&nbsp;<el-input v-model="params.deadline" size="mini" style="width: 130px;"/>，您的账户总积分&nbsp;<el-input v-model="params.point" size="mini"/>&nbsp;分，本月任务协作未达成，可继续进行开展。如有疑问请联系客服微信或致电平台客服电话：400-889-6116（逸创胜美平台）</p>
			</div>
			<span slot="footer" class="dialog-footer">
		    	<el-button @click="handleClose" size="small">取 消</el-button>
		    	<el-button type="primary" @click="doSure" size="small">确 定</el-button>
		  	</span>
		</el-dialog>
	</div>
</template>

<script>
import dayjs from 'dayjs'
import { sendTaskMsg } from '@/api/doctor/index'
export default {
	props: {
		visible: {
			type: Boolean,
			default: () => false
		},
		doctor: {
			type: Object,
			default: () => {}
		},
		msgCode: {
			type: String,
			default: () => ''
		}
	},
	data() {
		return {
			params: {
				msgCode: '',
				phone: '',
				doctorName: '',
				deadline: '',
				point: '',
				usedPoint: ''
			}
		};
	},
	mounted() {
		if (!this.doctor.sysUser || !this.doctor.sysUser.phonenumber) {
			this.handleClose()
			this.msgWarn('该医生手机号为空，请检查后再试');
		}
		this.params.phone = this.doctor.sysUser.phonenumber;
		this.params.msgCode = this.msgCode;
		this.params.doctorName = this.doctor.doctorName;
		this.params.deadline = dayjs().format('YYYY年MM月DD日');
		this.params.point = this.doctor.point;
		this.params.usedPoint = 0;
	},
	methods: {
		handleClose() {
			this.$emit('update:visible', false);
		},
		doSure() {
			this.$confirm('您确定要给该医生发送短信提醒吗？', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				sendTaskMsg(this.params).then(res => {
					if (res.code === 200) {
						this.msgSuccess(res.msg);
						this.handleClose();
					}
				})
			})
		}
	}
}
</script>

<style lang="scss" scoped>
	::v-deep .el-input { width: 70px; }
</style>
